//
//  RotationEffectView.swift
//  SwiftUIAnimation
//
//  Created by 李煜 on 2024/8/19.
//

import SwiftUI

struct RotationEffectView: View {
  @State private var isLoading = false
  var body: some View {
    // 下载指示器
    Circle()
      .trim(from: 0, to: 0.7)
      .stroke(.green, lineWidth: 5)
      .frame(width: 100, height: 100)
      .rotationEffect(isLoading ? .degrees(360) : .degrees(.zero))
//      .animation(.default.repeatForever(autoreverses: false), value: isLoading)
//          使用线性动画
      .animation(.linear(duration: 5).repeatForever(autoreverses: false), value: isLoading)
      .onTapGesture {
        isLoading = true
      }
  }
}

#Preview {
  RotationEffectView()
}
